﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OrderServe
{
    [Serializable]
    public class OrderDetails
    {
        private List<Good> goods;
        private double deposit;
        private DateTime orderDate;

        public OrderDetails()
        {
            this.goods = new List<Good>();
        }

        public OrderDetails(List<Good> goods, double deposit, DateTime orderDate)
        {
            this.goods = goods;
            this.deposit = deposit;
            this.orderDate = orderDate;
        }

      
        public double Deposit { get => deposit; set => deposit = value; }
        public DateTime OrderDate { get => orderDate; set => orderDate = value; }
        public List<Good> Goods { get => goods; set => goods = value; }


        public double Money()
        {
            double res = 0;
            for (int i = 0; i < Goods.Count; i++)
                res += Goods[i].Price * Goods[i].Num;
            return res;
        }

        public override bool Equals(object? obj)
        {
            OrderDetails? details = obj as OrderDetails;
            return details != null && details.GetHashCode() == this.GetHashCode();
        }
        public override int GetHashCode()
        {
            return orderDate.GetHashCode();
        }

        public override string ToString()
        {
            return orderDate.ToString();
        }

    }
}
